package com.fejal.bean;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;

import org.hibernate.annotations.Cascade;
import org.hibernate.annotations.CascadeType;
import org.hibernate.annotations.Fetch;
import org.hibernate.annotations.FetchMode;

@Entity
public class Nota implements Serializable {


	private static final long serialVersionUID = -3231257784245762863L;
	
	@Id
	@GeneratedValue (strategy = GenerationType.AUTO)
	private int codigoNota;
	
	@Column(nullable=false)
	private int tipoNota;
	
	@Column(precision=2, scale=5)
	private float valor;
	private boolean faltou;
	private int reposicao;
	
	@ManyToOne(fetch = FetchType.EAGER)
	@JoinColumn(name = "codigoHistorico", insertable = true, updatable = true, nullable=false)
	@Fetch(FetchMode.JOIN)
	@Cascade(CascadeType.SAVE_UPDATE)	
	private Historico historico;
	
	
	public int getCodigoNota() {
		return codigoNota;
	}
	public void setCodigoNota(int codigoNota) {
		this.codigoNota = codigoNota;
	}

	public float getValor() {
		return valor;
	}
	public void setValor(float valor) {
		this.valor = valor;
	}
	public boolean isFaltou() {
		return faltou;
	}
	public void setFaltou(boolean faltou) {
		this.faltou = faltou;
	}
	public int getReposicao() {
		return reposicao;
	}
	public void setReposicao(int reposicao) {
		this.reposicao = reposicao;
	}
	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + codigoNota;
		return result;
	}
	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		Nota other = (Nota) obj;
		if (codigoNota != other.codigoNota)
			return false;
		return true;
	}
	public Historico getHistorico() {
		return historico;
	}
	public void setHistorico(Historico historico) {
		this.historico = historico;
	}
	public int getTipoNota() {
		return tipoNota;
	}
	public void setTipoNota(int tipoNota) {
		this.tipoNota = tipoNota;
	}
	
}
